package com.api.main.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;

import java.io.OutputStream;
import java.util.List;

public class ExcelUtil {

    public static void export(OutputStream outputStream,
                              String sheetName,
                              List<List<String>> headers,
                              List<List<String>> data) {
        EasyExcel.write(outputStream)
                .head(headers)
                .registerWriteHandler(new SimpleColumnWidthStyleStrategy(30))
                .excelType(ExcelTypeEnum.XLSX)
                .sheet(sheetName)
                .doWrite(data);
    }
}